package com.zhx.zaxiang.服务定位模式;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.ServiceLocatorFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ParseConfig {

    /**
     * 服务定位模式
     * 可以通过枚举值定位到指定的接口实现类,,,只要实现类的名字和枚举类中定义的字符一样
     * 有点类似于简单工厂方法
     * @return
     */
    @Bean("serviceParsarFactory")
    public FactoryBean serviceLocatorFactoryBean(){
        ServiceLocatorFactoryBean factoryBean = new ServiceLocatorFactoryBean();
        factoryBean.setServiceLocatorInterface(ParserFactory.class);

        return factoryBean;
    }
}
